#ifndef ASSIMP_BYPASS_LOG
#define ASSIMP_BYPASS_LOG

#include <string>

#include <assimp/LogStream.h>
#include <assimp/Logger.h>

#include "../Log.h"

using namespace Assimp;

class AssimpBypassLog : public LogStream
{
public:
    
    AssimpBypassLog(Log *log, Logger::ErrorSeverity severity)
    {
        this->errLog = log;
        this->severity = severity;
    }

    ~AssimpBypassLog()
    {
    }

    void write(const char* message)
    {
        std::string s = message;
        std::string logMessage = s.substr(7,s.find_last_of('\n')-2); //remove logseverity from defaultlogger-message
        if(severity == Logger::DEBUGGING)
        {
            errLog->LogDebug(logMessage);
        }
        else
        if(severity == Logger::INFO)
        {
            errLog->LogInfo(logMessage);
        }
        else
        if(severity == Logger::WARN)
        {
            errLog->LogWarn(logMessage);
        }
        else
        if(severity == Logger::ERR)
        {
            errLog->LogError(logMessage);
        }
    }

private:
    Logger::ErrorSeverity severity;
    Log *errLog;
};

#endif //ASSIMP_BYPASS_LOG
